const cheerio = require("cheerio");
const http = require("http");

http.get("http://192.168.42.166:3000" , (res) => {
    let str = '';
    res.on("data" , (chunk) => {
        str += chunk;
    })
    res.on("end" , () => {
        // console.log(str);
        let $ = cheerio.load(str);
        console.log($(".newslist li").length);
        // console.log($(".newslist li").eq(1).html());
        // console.log($(".newslist li").html());
        for(let i = 0 ; i < $(".newslist li").length ; i++) {
            console.log($(".newslist li").eq(i).html());
            //给元素添加class
            $(".newslist li").attr(""); 
        }
    })
})

//对于cheerio其实就是对html进行一个结构的提取